package com.ajax;

import com.alibaba.fastjson.JSON;

/**
 * @author wzm
 * @create 2023-07-17 14:43
 * project_name:javaweb2306
 * file:FastJsonDemo
 */
public class FastJsonDemo {
    public static void main(String[] args) {
        //java对象==>json字符串
        User  user = new User(1,"刘德华","昆明");
        String s = JSON.toJSONString(user);
        System.out.println("s = " + s);
        //返回给前端


        //json字符串===>java对象
        s ="{\"address\":\"昆明\",\"id\":1,\"username\":\"刘德华\"}";
        User user1 = JSON.parseObject(s, User.class);
        System.out.println("user1 = " + user1);
        //前端过来的数据处理作为参数使用
    }
}
